Skip to content

Conversation

@rlaope
Copy link
Contributor

@rlaope rlaope commented Oct 16, 2024

Improvement for BatchMessagingMessageConverter.toMessage()

While analyzing the toMessage() function of BatchMessagingMessageConverter, improvements were made. We have worked on improving it accordingly.

  1. Replace traditional loops with Java Stream API for processing collections. This enhances code conciseness and readability, allowing for functional-style operations on data.
private void processRecord(ConsumerRecord<?, ?> record, List<Object> payloads, List<Object> keys,
			List<String> topics, List<Integer> partitions, List<Long> offsets,
			List<String> timestampTypes, List<Long> timestamps, List<Map<String, Object>> convertedHeaders,
			List<Headers> natives, List<ConsumerRecord<?, ?>> raws, List<ConversionException> conversionFailures,
			Map<String, Object> rawHeaders, Type type) {
  // proceedRecord..
}
  1. Utilize Optional to handle potential null values more gracefully.
  2. Separate function that prints log once

I think The analysis of the toMessage() code is expected to become more convenient.

@sobychacko sobychacko added this to the 3.3.0-RC1 milestone Oct 21, 2024
@sobychacko sobychacko merged commit 6f79247 into spring-projects:main Oct 21, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants